package cn.bone.motan.mashan.server;


import cn.bone.motan.common.MoRequest;
import cn.bone.motan.common.MoResponse;
import cn.bone.motan.demo1.api.ServerApi;
import cn.bone.motan.mashan.data.RouteData;
import cn.bone.motan.mashan.data.TempConfig;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


/**
 * Created by MD-01 on 2017/3/13.
 * 接收来自gateway的请求
 */
@Service
public class LocalService implements ServerApi{

    private Logger logger = LoggerFactory.getLogger("ms-server");

    @Override
    public MoResponse execute(MoRequest request) {

        logger.info("收到来自己本域gateway的消息");

        if(request==null){
            return MoResponse.error("参数不能为空");
        }
        RouteData routeData = TempConfig.routeData;
        return MoResponse.ok(JSON.toJSONString(routeData));
    }
}
